package com.gmp.thewizard;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.Log;

public class Avatar {

	private float x;
	private float y;
	private float r;
	private Paint color;
	private static final String TAG = "Avatar";
	private boolean touched;
	
	public Avatar(float x, float y, float r){
		this.x = x;
		this.y = y;
		this.r = r;
		color = new Paint(Paint.ANTI_ALIAS_FLAG);
		color.setColor(0xFFFF0000);
		
	}
	
	protected void onDraw(Canvas canvas){
		//Log.v(TAG, "in onDraw()");
		canvas.drawCircle(x, y, r, color);
	}
	
	protected void setPos(float x, float y){
		Log.v(TAG, "in setPos()");
		this.x = x;
		this.y = y;
	}
	
	protected boolean isTouched(){
		return touched;
	}
	
	protected void setTouched(boolean touched){
		this.touched = touched;
	}
	
	protected void handleActionDown(float xevent, float yevent){
		Log.v(TAG, "in handleActionDown()");
		Log.v(TAG, "avatar coord x=" + x + ", y=" + y);
		if(xevent >= x - r && xevent <= x + r){
			if(yevent >= y - r && yevent <= y + r){
				setTouched(true);
			} else
				setTouched(false);
		} else
			setTouched(false);
		Log.v(TAG, "is touched ? " + isTouched());
	}
}
